package com.lianwei.service.impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lianwei.dao.GoodsMapper;
import com.lianwei.pojo.Goods;
import com.lianwei.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class GoodsServiceImpl implements GoodsService {
    @Autowired
    GoodsMapper goodsMapper;

    @Override
    public Integer addGood(Goods goods) {
        int i = goodsMapper.addGoods(goods);
        return i;
    }

    @Override
    public Integer deleteGood(int id) {
        int i = goodsMapper.deleteGoodsById(id);
        return i;
    }

    @Override
    public Integer updateGood(Goods goods, int id) {
        int i = goodsMapper.updateGoods(goods, id);
        return i;
    }

    @Override
    public List<Goods> queryGoods() {
        List<Goods> goodsList = goodsMapper.getGoods();
        return goodsList;
    }

    @Override
    public Goods getGoodsById(int id) {
        Goods goods = goodsMapper.getGoodsById(id);
        return goods;
    }

    @Override
    public List<Goods> getGoodsLike(String name) {
        List<Goods> goodsList=goodsMapper.getGoodsLike(name);
        return goodsList;
    }
    @Override
    public List<Goods> getGoodsByCategory(int categoryId) {
        List<Goods> goodsList=goodsMapper.getGoodsByCategoryId(categoryId);
        return goodsList;
    }

}
